package org.lqk.pool.netty;

import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by bert on 16-5-9.
 */
@Component
public class NettyClient {
    @Autowired
    private GenericSocketChannelPool genericSocketChannelPool;

    public void send(String msg) throws Exception {
        Channel channel =  genericSocketChannelPool.borrowSocketChannel();
        ChannelFuture f = channel.writeAndFlush(msg);
        f.sync();
    }
}
